<?php
namespace app\cms\controller;
/* *
 * CMS内容管理系统前台
 * */
class DefaultController extends \app\base\controller\DefaultController{
	
	public function __construct(){
		parent::__construct();
        $condition['url'] = COME_URL;
		$website = model('website','admin')->_find($condition); 
		$website = filter_string($website,array(),1);
        $this->website = $website?$website:model('setting','cms')->_select();
    }

	//栏目
	public function lists(){
		$uid = form('get.uid',0,intval);
		$lists = model('channel')->_finds($uid,'id,website_id,name,url,uptime,tpl_list,exts_mid');
		if(!$lists['tpl_list']){
			$this->pageError('404 Not Found 未绑定栏目模板');
		}
		$path = model('defaults')->lists_path($uid);
		$this->assign('lists',$lists);
		$this->assign('path',$path);
		$this->WebDisplay($lists['tpl_list']);
	}

	//单页
	public function page(){
		$uid = form('get.uid',0,intval);
		$page = model('diypage')->_find(array('id'=>$uid));
		if(!$page['tpl_channel']){
			$this->pageError('404 Not Found 未绑定单页模板');
		}
		foreach ($page as $key => $value) {
			$str[$key] = htmlspecialchars_decode($value);
		}
		$this->assign('page',$str);
		$this->WebDisplay($page['tpl_channel']);
	}

	//内容
	public function read(){
		$uid = form('get.uid',0,intval);
		$rel = model('index')->_finds($uid);
		if(!$rel[0]['tpl_content']){
			$this->pageError('404 Not Found 未绑定内容模板!');
		}
		$path = model('defaults')->lists_path($rel[0][id]);
		$this->assign('path',$path);
		$this->assign('lists',$rel[0]);
		$this->assign('read',$rel[1]);
		$this->WebDisplay($rel[0]['tpl_content']);
	}

	//扩展内容
	public function extread(){
		$this->WebDisplay();
	}

	//专题模板
	public function topic(){
		$this->WebDisplay();
	}
}